package cn.virens.oauth.request.principal;

import cn.virens.common.exception.APIException;
import cn.virens.common.utils.objcet.ObjectUtil;

import java.io.Serializable;
import java.security.Principal;
import java.time.LocalDateTime;

/**
 * 登录用户信息包装对象
 *
 * @author virens
 */
@SuppressWarnings("serial")
public class DelegatePrincipal implements Principal, Serializable {
    private LocalDateTime expireTime; // 过期时间
    private LocalDateTime retryTime; // 重置时间
    private LocalDateTime loginTime; // 登录时间

    private String loginAuth; // 登录参数

    private Boolean tenantSuper; // 超管租户
    private String tenantName; // 租户名称
    private String tenantId; // 租户编号

    private String departName;
    private String departId;

    private String areaName;
    private String areaId;

    private String roleName;
    private String roleId;

    private String avatar;
    private String uname;
    private String uuid;

    public void setExpireTime(LocalDateTime expireTime) {
        this.expireTime = expireTime;
    }

    public void setRetryTime(LocalDateTime retryTime) {
        this.retryTime = retryTime;
    }

    public void setLoginTime(LocalDateTime loginTime) {
        this.loginTime = loginTime;
    }

    public void setLoginAuth(String loginAuth) {
        this.loginAuth = loginAuth;
    }

    public void setTenantSuper(Boolean tenantSuper) {
        this.tenantSuper = tenantSuper;
    }

    public void setTenantName(String tenantName) {
        this.tenantName = tenantName;
    }

    public void setDepartName(String departName) {
        this.departName = departName;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public void setDepartId(String departId) {
        this.departId = departId;
    }

    public void setAreaName(String areaName) {
        this.areaName = areaName;
    }

    public void setAreaId(String areaId) {
        this.areaId = areaId;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public void setRoleId(String roleId) {
        this.roleId = roleId;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public void setUname(String uname) {
        this.uname = uname;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public LocalDateTime getExpireTime() {
        return expireTime;
    }

    public LocalDateTime getRetryTime() {
        return retryTime;
    }

    public LocalDateTime getLoginTime() {
        return loginTime;
    }

    public String getLoginAuth() {
        return loginAuth;
    }

    public Boolean getTenantSuper() {
        return tenantSuper;
    }

    public String getTenantName() {
        return tenantName;
    }

    public String getTenantId() {
        return tenantId;
    }

    public String getDepartName() {
        return departName;
    }

    public String getDepartId() {
        return departId;
    }

    public String getAreaName() {
        return areaName;
    }

    public String getAreaId() {
        return areaId;
    }

    public String getRoleName() {
        return roleName;
    }

    public String getRoleId() {
        return roleId;
    }

    public String getAvatar() {
        return avatar;
    }

    public String getUname() {
        return uname;
    }

    public String getUuid() {
        return uuid;
    }

    @Override
    public String getName() {
        return uuid;
    }

    @Override
    public boolean equals(Object obj) throws APIException {
        return ObjectUtil.equals(obj, this);
    }

    @Override
    public String toString() throws APIException {
        return getUuid() + ":" + getLoginAuth();
    }

    @Override
    public int hashCode() throws APIException {
        return ObjectUtil.hash(getUuid());
    }
}
